<?php

namespace Admin\Controller;
use Admin\Builder\AdminConfigBuilder;

class ActivityController  extends AdminController {
	public function index(){
		$exh	=	M('TbExhinf');
		$zname = I('zname', '', 'text');
		$map['cID'] = UID;
		if ($zname !== '') {
			$map['zname'] = array('like', '%' . (string)$zname . '%');
		}        
 		$list = $this->lists($exh, $map); 

		int_to_string($list,array('zstatus'=>array(0=>'报名中',1=>'进行中',2=>'已结束')));              //数字转为字符串
		
		$this->assign('_list', $list);
		$this->display();
	}

	public function add(){
		$this->display('edit');
	}
    
	public function tender(){
		$this->display();
	}
	
	public function zdetail(){
		$id=I('id');
		$model	=	M('TbExhinf');
		/* $data = $model->join('duijie_tb_techol on duijie_tb_coninf.cid=duijie_tb_techol.id')
		 ->join('duijie_tb_tecach on duijie_tb_coninf.jcid=duijie_tb_tecach.id')
		->join('duijie_tb_tecdem on duijie_tb_coninf.jqid=duijie_tb_tecdem.id')
		->find($id); */
		$data=$model->find($id);
		$this->assign('data', $data);
		$this->display();
	}
    
	public function exhdem(){
		$id=I('id');
		$exhdem = M('TbExhdem');
		$map['id']=$id;
/* 		$list=$exhdem->join('duijie_tb_demand on duijie_tb_exhdem.xID=duijie_tb_demand.id')
		       ->join('duijie_tb_tecdem on duijie_tb_demand.rid=duijie_tb_tecdem.id')
		       ->where($map)->select($id); */
	/* 	$list = $this->lists($exhdem, $map);  */
		$sql='SELECT * from duijie_tb_exhdem,duijie_tb_demand,duijie_tb_tecdem 
         WHERE duijie_tb_exhdem.xID=duijie_tb_demand.id AND duijie_tb_demand.rid=duijie_tb_tecdem.id';
		$list=$exhdem->where($map)->query($sql);
		
		int_to_string($list,array('xdstatus'=>array(0=>'未对接',1=>'对接中',2=>'对接结束')));              //数字转为字符串
		
		$this->assign('_list', $list);
		$this->display();
	}
	
	public function collectdem(){
		$holdem = M('TbHoldem');
		$map['holID']=UID;
		/* 		$list=$exhdem->join('duijie_tb_demand on duijie_tb_exhdem.xID=duijie_tb_demand.id')
		 ->join('duijie_tb_tecdem on duijie_tb_demand.rid=duijie_tb_tecdem.id')
		->where($map)->select($id); */
		/* 	$list = $this->lists($exhdem, $map);  */
		$sql='SELECT * FROM  duijie_tb_holdem,duijie_tb_demand,duijie_tb_tecdem
         WHERE duijie_tb_holdem.demID = duijie_tb_demand.id AND  duijie_tb_demand.rid=duijie_tb_tecdem.id';
		$list=$holdem->where($map)->query($sql);
	
		int_to_string($list,array('xdstatus'=>array(0=>'未对接',1=>'对接中',2=>'对接结束')));              //数字转为字符串
	
		$this->assign('_list', $list);
		$this->display();
	}
	
	public function fielddem(){
		$demand=M('TbDemand');
		$sql='SELECT * FROM duijie_tb_demand,duijie_tb_techol,duijie_tb_tecdem
             WHERE duijie_tb_demand.field=duijie_tb_techol.field and duijie_tb_demand.rid=duijie_tb_tecdem.id';
		
		$map['duijie_tb_techol.id']=UID;
				
		$list=$demand->where($map)->query($sql);
		int_to_string($list,array('xdstatus'=>array(0=>'未对接',1=>'对接中',2=>'对接结束')));              //数字转为字符串
		
		$this->assign('_list', $list);
		$this->display();
	}
	
	public function save(){
		$model	=	M('TbConinf');
		$con	=	$model->create();
		if(empty($con['id'])){
			$con['cID']=UID;
			$model->add($con);
			$this->success("合同添加成功！",U('index'));
		}else {
			$model->save($con);
			$this->success("合同修改成功！",U('index'));
		}
	}
	public function del(){
		$map['id']	=   I('id');
		$this->delete('TbPatent',$map,array('success' => '专利删除成功！', 'error' => '专利删除失败！'));
	}
	// 	public function edit(){
	// 		$builder = new AdminConfigBuilder();
	// 		$data = $builder->handleConfig();
	// 		$builder->keyMultiImage('', '', '');

	// 		$builder->display();
	// 	}

}